<template>
  <div class="app-container">
    <el-table :data="userList" style="width: 100%;margin-top:30px;" border>
      <el-table-column align="center" label="编号" width="220">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="昵称" width="220">
        <template slot-scope="scope">
          {{ scope.row.nickname }}
        </template>
      </el-table-column>
      <!-- <el-table-column align="header-center" label="头像">
        <template slot-scope="scope">
          {{ scope.row.avatar }}
        </template>
      </el-table-column> -->
      <el-table-column align="center" label="操作">
        <template>
          <el-button type="primary" size="small">编辑</el-button>
          <el-button type="danger" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <br>
    <el-pagination
      background
      :current-page="page"
      :page-size="size"
      :page-count="pages"
      layout="prev, pager, next, sizes, total"
      :total="total"
      @current-change="pageChange"
      @size-change="sizeChange"
    />
  </div>
</template>

<script>
import { getUsers } from '@/api/user'

export default {
  data() {
    return {
      page: 1,
      size: 3,
      total: 0,
      pages: 0,
      userList: []
    }
  },
  computed: {
  },
  mounted() {
    this.getUsers()
  },
  created() {

  },
  methods: {
    pageChange(page) {
      this.page = page
      this.getUsers()
    },
    sizeChange(size) {
      this.size = size
      this.getUsers()
    },
    async getUsers() {
      // debugger
      const res = await getUsers(this.page, this.size)
      this.userList = res.data.data
      this.total = res.data.total
      this.pages = res.data.pages
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  .roles-table {
    margin-top: 30px;
  }
  .permission-tree {
    margin-bottom: 30px;
  }
}
</style>
